<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./../../WEB-INF/templates/newMainCandidateTemplate.xhtml">
            <ui:define name="content">
                <h:outputStylesheet library="css" name="candidate/candidate.css"></h:outputStylesheet> 
                <h:outputStylesheet library="css" name="candidate/notifications.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="candidate/notifications_desktop.css" media="screen and (min-width:1025px) and (max-width:1600px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="candidate/notifications_desktop_wide.css" media="screen and (min-width : 1601px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="candidate/notifications_tablet.css" media="screen and (min-device-width : 768px) and (max-device-width : 1024px), screen and (max-width:1024px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="candidate/notifications_smartphone.css" media="screen and (min-device-width : 320px) and (max-device-width : 767px), screen and (max-width:767px)"></h:outputStylesheet>
                
                <h:form id="notificationsCandidateViewForm" styleClass="fullWidthContainer">
                    <p:growl id="growl"/>
                    <p:panel styleClass="fullPanelMargin notificationBackgroundTitle redSectionBackground noMargin noPaddingTitle  redBorder" header="#{messages.Notifications}">
                        <p:panel id="notificationsDatatable" styleClass="noBorder noPadding noMargin">
                            <p:commandButton rendered="#{notificationsUserBean.entityList!=null and !notificationsUserBean.entityList.isEmpty()}" styleClass="grayBackgroundStrong" id="markAsViewAllNotifications"  value="#{messages.MarkAsViewAll}" update="notificationsCandidateViewForm:notificationsDatatable :barForm :barFormSmartphone" actionListener="#{notificationsUserBean.markAllNotificationsAsView()}"/>  
                        
                            <p:dataTable   var="notification" value="#{notificationsUserBean.entityList}" rowKey="#{notification.idNotification}" 
                                           paginator="true" rows="30" emptyMessage="#{messages.NoNotifications}"
                                          paginatorTemplate="" styleClass="noHeaderTable"
                                          rowStyleClass="#{notification.isNotificated == false ? 'notificationNew' : 'notificationOld'}"
                                          selection="#{notificationsUserBean.chosenEntity}">  

                                <p:ajax event="rowSelectRadio" listener="#{notificationsUserBean.notificationRead()}"   
                                       update=":notificationsCandidateViewForm:notificationsDatatable :barForm :barFormSmartphone" />
                                <p:column selectionMode="single" width="20px"/>
                                <p:column >  
                                    <h:outputText  value="#{notification.description}" />  

                                </p:column>  


                            </p:dataTable>  
                        </p:panel>
                    </p:panel>

                </h:form>
                <h:form>
                    <p:socket onMessage="handleMessageNt" channel="/notification/#{editCandidateBean.candidate.user.idUser}"/>  
                    <p:remoteCommand async="true" name="ntCommand"  update=":notificationsCandidateViewForm:notificationsDatatable" ></p:remoteCommand>
                <script type="text/javascript">  
                    function handleMessageNt(notificationData) {
                        ntCommand([{name: 'idNotification', value: notificationData}]);
                    }  
                </script>  
                </h:form>
                
            </ui:define>
        </ui:composition>

    </body>
</html>

